package view.mt4j.util;

import org.mt4j.components.MTComponent;
import org.mt4j.input.inputProcessors.IGestureEventListener;
import org.mt4j.input.inputProcessors.IInputProcessor;
import org.mt4j.input.inputProcessors.MTGestureEvent;
import org.mt4j.input.inputProcessors.componentProcessors.dragProcessor.DragProcessor;
import org.mt4j.input.inputProcessors.componentProcessors.rotateProcessor.RotateProcessor;
import org.mt4j.input.inputProcessors.componentProcessors.scaleProcessor.ScaleProcessor;

public class ProcessorHelper {

	public static void delegateGestureEventTo(final MTComponent delegate,
			Class<? extends IInputProcessor> clazz, MTComponent component) {
		component.addGestureListener(clazz,
				new IGestureEventListener() {
					@Override
					public boolean processGestureEvent(
							MTGestureEvent gestureEvent) {
						gestureEvent.setTarget(delegate);
						return delegate.processGestureEvent(gestureEvent);
					}
				});

	}
	
	public static void delegateDragScaleRotateEventTo(MTComponent delegate,
			MTComponent component) {
		ProcessorHelper.delegateGestureEventTo(delegate, DragProcessor.class,
				component);
		ProcessorHelper.delegateGestureEventTo(delegate, ScaleProcessor.class,
				component);
		ProcessorHelper.delegateGestureEventTo(delegate, RotateProcessor.class,
				component);
	}

}
